/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecbenchmarks.movingpeaks;

import ecbenchmarks.util.CommonMath;

/**
 *
 * @author jcrada
 */
public class PeakFunctionCone implements PeakFunction {

    @Override
    public double f(final double[] x,  final double[][] peak, int peakIndex) {
        double dummy = CommonMath.Pow2(x[0] - peak[peakIndex][0]);
        for (int j = 1; j < x.length; j++) {
            dummy += CommonMath.Pow2(x[j] - peak[peakIndex][j]);
        }
        return peak[peakIndex][x.length + 1] - 
                (peak[peakIndex][x.length] * Math.sqrt(dummy));

    }
}
